/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package emf.entity_relationship.model.entityrelationship.impl;

import emf.entity_relationship.model.entityrelationship.Connection_Entity_Relationship;
import emf.entity_relationship.model.entityrelationship.Entity;
import emf.entity_relationship.model.entityrelationship.EntityrelationshipPackage;
import emf.entity_relationship.model.entityrelationship.Relationship;
import emf.entity_relationship.model.entityrelationship.impl.RelationshipImpl;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Connection Entity Relationship</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link emf.entity_relationship.model.entityrelationship.impl.Connection_Entity_RelationshipImpl#getMinimum_cardinality <em>Minimum cardinality</em>}</li>
 *   <li>{@link emf.entity_relationship.model.entityrelationship.impl.Connection_Entity_RelationshipImpl#getRole <em>Role</em>}</li>
 *   <li>{@link emf.entity_relationship.model.entityrelationship.impl.Connection_Entity_RelationshipImpl#getConnection_Entity <em>Connection Entity</em>}</li>
 *   <li>{@link emf.entity_relationship.model.entityrelationship.impl.Connection_Entity_RelationshipImpl#getConnection_Relationship <em>Connection Relationship</em>}</li>
 *   <li>{@link emf.entity_relationship.model.entityrelationship.impl.Connection_Entity_RelationshipImpl#getMaximum_cardinality <em>Maximum cardinality</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class Connection_Entity_RelationshipImpl extends EObjectImpl implements Connection_Entity_Relationship {
	/**
	 * The default value of the '{@link #getMinimum_cardinality() <em>Minimum cardinality</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMinimum_cardinality()
	 * @generated
	 * @ordered
	 */
	protected static final String MINIMUM_CARDINALITY_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getMinimum_cardinality() <em>Minimum cardinality</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMinimum_cardinality()
	 * @generated
	 * @ordered
	 */
	protected String minimum_cardinality = MINIMUM_CARDINALITY_EDEFAULT;

	/**
	 * The default value of the '{@link #getRole() <em>Role</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRole()
	 * @generated
	 * @ordered
	 */
	protected static final String ROLE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getRole() <em>Role</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRole()
	 * @generated
	 * @ordered
	 */
	protected String role = ROLE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getConnection_Entity() <em>Connection Entity</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConnection_Entity()
	 * @generated
	 * @ordered
	 */
	protected Entity connection_Entity;

	/**
	 * The cached value of the '{@link #getConnection_Relationship() <em>Connection Relationship</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConnection_Relationship()
	 * @generated
	 * @ordered
	 */
	protected Relationship connection_Relationship;

	/**
	 * The default value of the '{@link #getMaximum_cardinality() <em>Maximum cardinality</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMaximum_cardinality()
	 * @generated
	 * @ordered
	 */
	protected static final String MAXIMUM_CARDINALITY_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getMaximum_cardinality() <em>Maximum cardinality</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMaximum_cardinality()
	 * @generated
	 * @ordered
	 */
	protected String maximum_cardinality = MAXIMUM_CARDINALITY_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Connection_Entity_RelationshipImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return EntityrelationshipPackage.Literals.CONNECTION_ENTITY_RELATIONSHIP;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getMinimum_cardinality() {
		return minimum_cardinality;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMinimum_cardinality(String newMinimum_cardinality) {
		String oldMinimum_cardinality = minimum_cardinality;
		minimum_cardinality = newMinimum_cardinality;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__MINIMUM_CARDINALITY, oldMinimum_cardinality, minimum_cardinality));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getRole() {
		return role;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRole(String newRole) {
		String oldRole = role;
		role = newRole;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__ROLE, oldRole, role));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Entity getConnection_Entity() {
		if (connection_Entity != null && connection_Entity.eIsProxy()) {
			InternalEObject oldConnection_Entity = (InternalEObject)connection_Entity;
			connection_Entity = (Entity)eResolveProxy(oldConnection_Entity);
			if (connection_Entity != oldConnection_Entity) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__CONNECTION_ENTITY, oldConnection_Entity, connection_Entity));
			}
		}
		return connection_Entity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Entity basicGetConnection_Entity() {
		return connection_Entity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setConnection_Entity(Entity newConnection_Entity) {
		Entity oldConnection_Entity = connection_Entity;
		connection_Entity = newConnection_Entity;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__CONNECTION_ENTITY, oldConnection_Entity, connection_Entity));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Relationship getConnection_Relationship() {
		if (connection_Relationship != null && connection_Relationship.eIsProxy()) {
			InternalEObject oldConnection_Relationship = (InternalEObject)connection_Relationship;
			connection_Relationship = (Relationship)eResolveProxy(oldConnection_Relationship);
			if (connection_Relationship != oldConnection_Relationship) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__CONNECTION_RELATIONSHIP, oldConnection_Relationship, connection_Relationship));
			}
		}
		return connection_Relationship;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Relationship basicGetConnection_Relationship() {
		return connection_Relationship;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setConnection_Relationship(Relationship newConnection_Relationship) {
		Relationship oldConnection_Relationship = connection_Relationship;
		connection_Relationship = newConnection_Relationship;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__CONNECTION_RELATIONSHIP, oldConnection_Relationship, connection_Relationship));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getMaximum_cardinality() {
		return maximum_cardinality;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMaximum_cardinality(String newMaximum_cardinality) {
		String oldMaximum_cardinality = maximum_cardinality;
		maximum_cardinality = newMaximum_cardinality;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__MAXIMUM_CARDINALITY, oldMaximum_cardinality, maximum_cardinality));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__MINIMUM_CARDINALITY:
				return getMinimum_cardinality();
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__ROLE:
				return getRole();
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__CONNECTION_ENTITY:
				if (resolve) return getConnection_Entity();
				return basicGetConnection_Entity();
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__CONNECTION_RELATIONSHIP:
				if (resolve) return getConnection_Relationship();
				return basicGetConnection_Relationship();
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__MAXIMUM_CARDINALITY:
				return getMaximum_cardinality();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__MINIMUM_CARDINALITY:
				setMinimum_cardinality((String)newValue);
				return;
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__ROLE:
				setRole((String)newValue);
				return;
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__CONNECTION_ENTITY:
				setConnection_Entity((Entity)newValue);
				return;
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__CONNECTION_RELATIONSHIP:
				setConnection_Relationship((Relationship)newValue);
				return;
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__MAXIMUM_CARDINALITY:
				setMaximum_cardinality((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__MINIMUM_CARDINALITY:
				setMinimum_cardinality(MINIMUM_CARDINALITY_EDEFAULT);
				return;
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__ROLE:
				setRole(ROLE_EDEFAULT);
				return;
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__CONNECTION_ENTITY:
				setConnection_Entity((Entity)null);
				return;
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__CONNECTION_RELATIONSHIP:
				setConnection_Relationship((Relationship)null);
				return;
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__MAXIMUM_CARDINALITY:
				setMaximum_cardinality(MAXIMUM_CARDINALITY_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__MINIMUM_CARDINALITY:
				return MINIMUM_CARDINALITY_EDEFAULT == null ? minimum_cardinality != null : !MINIMUM_CARDINALITY_EDEFAULT.equals(minimum_cardinality);
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__ROLE:
				return ROLE_EDEFAULT == null ? role != null : !ROLE_EDEFAULT.equals(role);
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__CONNECTION_ENTITY:
				return connection_Entity != null;
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__CONNECTION_RELATIONSHIP:
				return connection_Relationship != null;
			case EntityrelationshipPackage.CONNECTION_ENTITY_RELATIONSHIP__MAXIMUM_CARDINALITY:
				return MAXIMUM_CARDINALITY_EDEFAULT == null ? maximum_cardinality != null : !MAXIMUM_CARDINALITY_EDEFAULT.equals(maximum_cardinality);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (minimum_cardinality: ");
		result.append(minimum_cardinality);
		result.append(", role: ");
		result.append(role);
		result.append(", maximum_cardinality: ");
		result.append(maximum_cardinality);
		result.append(')');
		return result.toString();
	}

} //Connection_Entity_RelationshipImpl
